package InetAddress;

import java.net.InetAddress;
import java.net.UnknownHostException;

/*
InetAddress 此类表示Internet协议（IP）地址。
static InetAddress getByName(String host)确定主机名称的IP地址
String getHostName()获取此IP地址的主机名。
String getHostAddress()返回文本显示中的IP地址字符串。
 */
public class copy {
    public static void main(String[] args) throws UnknownHostException {
        //static InetAddress getByName(String host)确定主机名称的IP地址
//        InetAddress address=InetAddress.getByName("LAPTOP-QF77OJO7");
        InetAddress address=InetAddress.getByName("192.168.146.1");

        //String getHostName()获取此IP地址的主机名。
        String name = address.getHostName();

        //String getHostAddress()返回文本显示中的IP地址字符串。
        String hostAddress = address.getHostAddress();

        System.out.println("IP地址"+address);
        System.out.println("主机名"+name);
        System.out.println("IP"+hostAddress);

    }
}
